﻿<!DOCTYPE HTML>
<html>
<head>
    <title>新增结算单明细</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="~/Content/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/jquery.bsgrid-1.37/merged/bsgrid.all.min.css" rel="stylesheet" />
    <link href="~/Content/jquery.bsgrid-1.37/css/skins/grid_bootstrap.min.css" rel="stylesheet" />

    <style type="text/css">
        code {
            padding: 0px 4px;
            color: #d14;
            background-color: #f7f7f9;
            border: 1px solid #e1e1e8;
        }
        /*#button button i{
            color:white;
        }*/
        #button button {
            font-family: 华文行楷;
            font-size: 16px;
            line-height: 14px;
        }

        .row label {
            font-family: 华文行楷;
            font-size: 16px;
        }

        .row input {
            width: 150px;
            height: 33px;
        }

        .lol th {
            font-family: 华文行楷;
            font-size: 16px;
        }
    </style>
</head>
<body>

    <div class="container">
        <div class="panel-heading" style="height:55px;margin-left:-4785px;margin-top:30px;">
            <div class="col-lg-10 col-sm-10 col-md-10 text-right" id="button">
                <button class="btn btn-brown" style="width:84px;" id="btnGuanbi"><i class="glyphicon glyphicon-remove" style="font-size:14px;"></i>关闭</button>
                <button class="btn btn-brown" style="width:84px;" id="btnYes"><i class="glyphicon glyphicon-floppy-saved" style="font-size:14px;"></i>确认</button>
                <button class="btn btn-brown" style="width:84px;" id="btnSelect"><i class=" glyphicon glyphicon-search" style="font-size:14px;"></i>查询</button>
            </div>
        </div>

        <h4 style="font-family:华文行楷;margin-left:-138px;color:cadetblue;margin-top:0px;">查询条件</h4>
        <div class="row" id="modInsertExaminee">
            <form id="" class="form-horizontal span24" action="/KeFangYuDing/KeFang/Insertnews" method="post">
                <div class="row">
                    <input type="hidden" id="SignID" name="SignID" />
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-167px;margin-top:-15px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">委托单号</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-17px;margin-top:3px;">
                            <input type="text" class="form-control" id="EtrustNmber" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-163px;margin-top:-14px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">柜号</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-15px;margin-top:2px;">
                            <input type="text" class="form-control" id="Cupboard" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-157px;margin-top:-14px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">封条号</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <input type="text" class="form-control" id="Seal" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:575px;margin-top:-36px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">还柜时间</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-17px;margin-top:1px;">
                            <input type="date" class="form-control" id="HuaiWeightTime" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:914px;margin-top:-36px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right" style="width:20px;">
                            <label class="control-label">至</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-10px;margin-top:1px;">
                            <input type="date" class="form-control" id="HuaiWeightTimes" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-167px;margin-top:1px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">客户简称</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-17px;margin-top:3px;">
                            <input type="text" class="form-control" id="ClientAbbreviation" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-165px;margin-top:3px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">提柜地点</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="TiGui"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-155px;margin-top:2px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">还柜地点</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="HuanGui"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-137px;margin-top:-1px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">船公司</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-17px;margin-top:3px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="Client"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:826px;margin-top:-37px;float:left">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">船名</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-15px;margin-top:2px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="ChineseName"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-172px;margin-top:4px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">航次</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <input type="text" class="form-control" id="HangCi" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-161px;margin-top:4px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">进出口岸</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="PortID"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-155px;margin-top:4px;float:left">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">目的港</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="GoalHarborID"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-136px;margin-top:1px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">承运公司</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-17px;margin-top:3px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="UndertakeID"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:824px;margin-top:-36px;float:left">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">状态</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="EtrustType">
                                <option value="">----请选择----</option>
                                <option value="运输完成">运输完成</option>
                                <option value="新单">新单</option>
                                <option value="已派车">已派车</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-173px;margin-top:2px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">司机</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="Chauffeur"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-159px;margin-top:2px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">车牌号</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-15px;margin-top:2px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="PlateNumbers"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-157px;margin-top:2px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">托架编号</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="BracketCode"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-136px;margin-top:0px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">订舱号</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-17px;margin-top:3px;">
                            <input type="text" class="form-control" id="BookingSpace" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:826px;margin-top:-37px;float:left">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">订单号</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-15px;margin-top:2px;">
                            <input type="text" class="form-control" id="IndentNumber" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-173px;margin-top:2px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">作业类别</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <input type="text" class="form-control" id="WorkCategory" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-162px;margin-top:2px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">车型</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <input type="text" class="form-control" id="CheXing" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-150px;margin-top:0px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">结算单位</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-17px;margin-top:3px;">
                            <input type="text" class="form-control" id="ReckoningUnit" name="" />
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-141px;margin-top:2px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">费用名称</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-15px;margin-top:2px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="ExpenseName"></select>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:824px;margin-top:-36px;">
                        <div class="col-lg-4 col-md-4 col-sm-4 text-right">
                            <label class="control-label">收付类型</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:1px;">
                            <select type="text" style="height:33px;width:150px;" class="form-control" id="SettleAccounts">
                                <option value="">----请选择----</option>
                                <option value="应收">应收</option>
                                <option value="应付">应付</option>
                                <option value="成本">成本</option>
                            </select>
                        </div>   @*在页面写下拉框的数据用于查询的时候，要用字符串string进行传参查询，记得要写上value值*@
                    </div>
                </div>
            </form>
        </div>

        @*编辑应收应付明细模态框*@
        <div class="row">
            <div class="modal bs-example-modal-sm" id="modBaseInfor">
                <div class="modal-dialog">
                    <div class="modal-content" style="width:560px;">
                        <div class="modal-header" style="height:47px;">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title" style="font-family:华文行楷;"><span class="glyphicon glyphicon-ok"></span>编辑应收应付明细</h4>
                            <h4 style="font-family:华文行楷;margin-left:-2px;color:cadetblue;margin-top:11px;">对账单信息</h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-horizontal" role="form" id="J_Form" action="" method="post">
                                <input type="hidden" id="ChargeID" name="ChargeID" />
                                <div class="form-group" style="margin-left:-4px;margin-top:6px;">
                                    <label class="control-label">结算单位</label>
                                    <input id="ReckoningUnit1" name="ReckoningUnit" style="width:185px;margin-left:72px;margin-top:-26px;" type="text" class="form-control" readonly />
                                </div>
                                <div class="form-group" style="margin-left:274px;margin-top:-53px;">
                                    <label class="control-label">委托单号</label>
                                    <input id="EtrustNmber1" name="EtrustNmber" style="width:185px;margin-left:72px;margin-top:-26px;" type="text" class="form-control" readonly />
                                </div>
                                <div class="form-group" style="margin-left:276px;margin-top:-3px;">
                                    <label class="control-label">费用名称</label>
                                    <input id="ExpenseName1" name="ExpenseName" style="margin-left:71px;margin-top:-26px;width:185px;" type="text" class="form-control"  readonly/>
                                </div>
                                <div class="form-group" style="margin-left:-4px;margin-top:-52px;">
                                    <label class="control-label">收付类型</label>
                                    <input id="SettleAccounts1" name="SettleAccounts" style="margin-left:71px;margin-top:-26px;width:185px;" type="text" class="form-control"  readonly/>
                                </div>
                                <div class="form-group" style="margin-left:-5px;margin-top:-2px;">
                                    <label class="control-label">金额</label>
                                    <input id="UnitPrice1" name="UnitPrice" style="margin-left:71px;margin-top:-26px;width:185px;" type="text" class="form-control"  />
                                </div>
                                <div class="form-group" style="margin-left:275px;margin-top:-52px;">
                                    <label class="control-label">汇率</label>
                                    <input id="Parities1" name="Parities" style="margin-left:71px;margin-top:-26px;width:185px;" type="text" class="form-control" readonly/>
                                </div>
                                <div style="margin-left:287px;font-family: 华文行楷;font-size:18px;">
                                    <button id="BtnSave" type="button" class="btn btn-warning">确定</button>
                                    <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        @*下方表格*@
        <div style="margin-left:-143px;margin-top:15px;">
            <table class="table table-hover choosetable" style="width:1373px;" id="tabInsertDetail">
                <thead>
                    <tr class="lol">
                        <th w_index="ChargeID" w_check="true"></th>
                        <th w_num="total_line">序号</th>
                        <th w_index="ExpenseName">费用名称</th>
                        <th w_index="SettleAccounts">收付类型</th>
                        <th w_index="UnitPrice">金额</th>
                        <th w_index="YiJieMoney">已结算</th>
                        <th w_index="UnitPrice">未结算</th>
                        <th w_index="Parities">汇率</th>
                        <th w_index="Currency">币种</th>
                        <th w_index="IndentNumber">订单号</th>
                        <th w_index="EtrustNmber">委托单号</th>
                        <th w_index="Cupboard">柜号</th>
                        <th w_index="Seal">封条号</th>
                        <th w_index="EtrustType">业务状态</th>
                        <th w_index="ClientAbbreviation">客户简称</th>
                        <th w_index="ReckoningUnit">结算单位</th>
                        <th w_index="CheXing">柜(车)型</th>
                        <th w_index="WorkCategory">作业类别</th>
                        <th w_index="HuaiWeightTime1">还柜时间</th>
                        <th w_render="setOperate">操作</th>
                    </tr>
                </thead>
            </table>
        </div>

        @*表格下方文本框*@
        <div style="width:1000px;height:35px;margin-left:0px;margin-top:10px;">
            <form class="form-horizontal" role="form" id="zuhechaxunfrom">
                <input type="reset" class="hidden" />
                <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:0px;margin-top:4px;">
                    <div class="col-lg-4 col-md-4 col-sm-4 text-right" style="margin-top:8px;">
                        <label class="control-label">本次应收</label>
                    </div>
                    <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:6px;">
                        <input type="text" class="form-control" id="BenCiYingS" name="BCYShou" readonly />
                    </div>
                </div>
                <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-72px;margin-top:4px;">
                    <div class="col-lg-4 col-md-4 col-sm-4 text-right" style="margin-top:8px;">
                        <label class="control-label">本次应付</label>
                    </div>
                    <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:6px;">
                        <input type="text" class="form-control" id="BenCiYingF" name="BCYFu" readonly />
                    </div>
                </div>
                <div class="col-lg-4 col-md-4 col-sm-4" style="margin-left:-72px;margin-top:4px;">
                    <div class="col-lg-4 col-md-4 col-sm-4 text-right" style="margin-top:8px;">
                        <label class="control-label">结算金额</label>
                    </div>
                    <div class="col-lg-8 col-md-8 col-sm-8 reset" style="margin-left:-13px;margin-top:6px;">
                        <input type="text" class="form-control" id="JieSuanM" name="SettleMoney" readonly />
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="~/Content/bootstrap-3.3.7-dist/js/jquery-2.0.3.min.js"></script>
    <script src="~/Content/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script src="~/Content/jquery.bsgrid-1.37/builds/merged/bsgrid.all.min.js"></script>
    <script src="~/Content/jquery.bsgrid-1.37/builds/js/lang/grid.zh-CN.min.js"></script>
    <script src="~/Content/layer/layer.js"></script>
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/js/customfunction.js"></script>
    <script src="~/Content/js/combobox.js"></script>

    <script>
        var tabInsertDetail;

        //打开页面就启用加载，必要
        $(document).ready(function () {

            //绑定提柜地点下拉框
            createSelect("TiGui", "SelecrDiDian");
            //绑定还柜地点下拉框
            createSelect("HuanGui", "SelecrDiDian");
            //绑定船名下拉框
            createSelect("ChineseName", "SelectShip");
            //绑定司机下拉框
            createSelect("Chauffeur", "SelectChauffeur");
            //绑定车牌下拉框
            createSelect("PlateNumbers", "SelectPlateNumbers");
            //绑定费用名称下拉框
            createSelect("ExpenseName", "SelectExpense");
            //绑定托架编号下拉框
            createSelect("BracketCode", "SelectBracket");
            //绑定船公司下拉框
            createSelect("Client", "SelectClient");
            //绑定进出口岸下拉框
            createSelect("PortID", "SelectPort");
            //绑定目的港下拉框
            createSelect("GoalHarborID", "SelectPort");
            //绑定承运公司下拉框
            createSelect("UndertakeID", "SelectClientt");
            //绑定结算方式下拉框
            createSelect("SettleWayID", "SelectSettleWay");
            //绑定付款方式下拉框
            createSelect("PayWayID", "SelectPayWay");

            $("#BenCiYingF").val(0);//本次应付  就是一开始让文本框显示值为0
            $("#BenCiYingS").val(0);//本次应收
            $("#JieSuanM").val(0);//结算金额            

            //点击表头的Input，为全选中(在此调用Pitch()进行选中相加减)
            $("#tabInsertDetail thead tr th").eq(0).click(function () {
                setTimeout(function () {
                    Pitch()
                }, 100)
            })

            tabInsertDetail = $.fn.bsgrid.init("tabInsertDetail", {
                url: "SelectInsertDetail",
                autoLoad: true,//是否自动加载
                pageSizeSelect: true,//分页大小选择下拉框
                pageSize: 8,//初始化每一页数据条数
                stripeRows: true,//隔行换色
                rowHoverColor: true,//鼠标滑过变色
                pagingLittleToolbar: true,//精简的图标按钮分页工具条
                displayBlankRows: true,//不显示空白行
                event: {
                    //当前行事件
                    customRowEvents: {
                        //(record行记录值,rowIndex行索引值,trObj:tr目标,options选择的东西)
                        click: function (record, rowIndex, trObj, options) {
                            Check("#tabInsertDetail tr", rowIndex + 1, record);
                            Pitch();  //在点击行事件调用金额自动相加，回填到文本框的方法
                            ChargeInfor(record);
                        }
                    }
                }
            });
        })

        //点击每一条结算单，金额会自动相加回填在下方文本框上
        function Pitch() {
            $("#BenCiYingF").val(0)
            $("#BenCiYingS").val(0)
            $("#JieSuanM").val(0)
            for (var i = 0; i < $("#tabInsertDetail tbody tr").length; i++) {
                if ($("#tabInsertDetail tbody tr").eq(i).children().eq(0).children().prop('checked') == true) {
                    if ($("#tabInsertDetail tbody tr").eq(i).children().eq(3).html() == "应收") {
                        var A = (parseFloat($("#tabInsertDetail tbody tr").eq(i).children().eq(4).html()) + parseFloat($("#BenCiYingS").val())).toFixed(3)
                        $("#BenCiYingS").val(A)
                    } else if ($("#tabInsertDetail tbody tr").eq(i).children().eq(3).html() == "应付") {
                        var B = (parseFloat($("#tabInsertDetail tbody tr").eq(i).children().eq(4).html()) + parseFloat($("#BenCiYingF").val())).toFixed(3)
                        $("#BenCiYingF").val(B)
                    }
                    var C = (parseFloat($("#BenCiYingS").val()) - parseFloat($("#BenCiYingF").val())).toFixed(3);
                    $("#JieSuanM").val(C);
                }
            }
        }

        //新增结算单多条件查询
        function tabInsertDetailSearch() {
            var EtrustNmber = $("#EtrustNmber").val();//委托单号
            var Cupboard = $("#Cupboard").val();//柜号
            var Seal = $("#Seal").val();//封条号
            var HuaiWeightTime = $("#HuaiWeightTime").val();//还柜时间
            var HuaiWeightTimes = $("#HuaiWeightTimes").val();
            var ClientAbbreviation = $("#ClientAbbreviation").val();//客户简称
            var TiGuiDiDianID = $("#TiGui").val();//提柜地点
            var HuaiGuiDiDianID = $("#HuanGui").val();//还柜地点
            var ClientID = $("#Client").val();//船公司
            var ShipID = $("#ChineseName").val();//船名
            var HangCi = $("#HangCi").val();//航次
            var PortID = $("#PortID").val();//进出口岸
            var GoalHarborID = $("#GoalHarborID").val();//目的港
            var UndertakeID = $("#UndertakeID").val();//承运公司
            var EtrustType = $("#EtrustType").val();//状态
            var ChauffeurID = $("#Chauffeur").val();//司机
            var VehicleInformationID = $("#PlateNumbers").val();//车牌号
            var BracketID = $("#BracketCode").val();//托架编号
            var BookingSpace = $("#BookingSpace").val();//订舱号
            var IndentNumber = $("#IndentNumber").val();//订单号
            var WorkCategory = $("#WorkCategory").val();//作业类别
            var CheXing = $("#CheXing").val();//车型
            var ReckoningUnit = $("#ReckoningUnit").val();//结算单位
            var ExpenseID = $("#ExpenseName").val();//费用名称
            var SettleAccounts = $("#SettleAccounts").val();//收付款类型

            if (EtrustNmber == undefined) { //委托单号
                EtrustNmber = "";
            }
            if (Cupboard == undefined) { //柜号
                Cupboard = "";
            }
            if (Seal == undefined) { //封条号
                Seal = "";
            }
            if (HuaiWeightTime == undefined) { //还柜时间
                HuaiWeightTime = "";
            }
            if (HuaiWeightTimes==undefined) {
                HuaiWeightTimes = "";
            }
            if (ClientAbbreviation == undefined) { //客户简称
                ClientAbbreviation = "";
            }
            if (TiGuiDiDianID == undefined) { //提柜地点
                TiGuiDiDianID = 0;
            }
            if (HuaiGuiDiDianID == undefined) { //还柜地点
                HuaiGuiDiDianID = 0;
            }
            if (ClientID == undefined) { //船公司
                ClientID = 0;
            }
            if (ShipID == undefined) { //船名
                ShipID = 0;
            }
            if (HangCi == undefined) { //航次
                HangCi = "";
            }
            if (PortID == undefined) { //进出口岸
                PortID = 0;
            }
            if (GoalHarborID == undefined) { //目的港
                GoalHarborID = 0;
            }
            if (UndertakeID == undefined) { //承运公司
                UndertakeID = 0;
            }
            if (EtrustType == undefined) { //状态
                EtrustType = "";
            }
            if (ChauffeurID == undefined) { //司机
                ChauffeurID = 0;
            }
            if (VehicleInformationID == undefined) { //车牌号
                VehicleInformationID = 0;
            }
            if (BracketID == undefined) { //托架编号
                BracketID = 0;
            }
            if (BookingSpace == undefined) { //订舱号
                BookingSpace = "";
            }
            if (IndentNumber == undefined) { //订单号
                IndentNumber = "";
            }
            if (WorkCategory == undefined) { //作业类别
                WorkCategory = "";
            }
            if (CheXing == undefined) { //车型
                CheXing = "";
            }
            if (ReckoningUnit == undefined) { //结算单位
                ReckoningUnit = "";
            }
            if (ExpenseID == undefined) { //费用名称
                ExpenseID = 0;
            }
            if (SettleAccounts == undefined) { //收付款类型
                SettleAccounts = "";
            }

            tabInsertDetail.search({ EtrustNmber: EtrustNmber, Cupboard: Cupboard, Seal: Seal, HuaiWeightTime: HuaiWeightTime, HuaiWeightTimes:HuaiWeightTimes,ClientAbbreviation: ClientAbbreviation, TiGuiDiDianID: TiGuiDiDianID, HuaiGuiDiDianID: HuaiGuiDiDianID, ClientID: ClientID, ShipID: ShipID, HangCi: HangCi, PortID: PortID, GoalHarborID: GoalHarborID, UndertakeID: UndertakeID, EtrustType: EtrustType, ChauffeurID: ChauffeurID, VehicleInformationID: VehicleInformationID, BracketID: BracketID, BookingSpace: BookingSpace, IndentNumber: IndentNumber, WorkCategory: WorkCategory, CheXing: CheXing, ReckoningUnit: ReckoningUnit, ExpenseID: ExpenseID, SettleAccounts: SettleAccounts })
        }

        //点击查询按钮进行多条件查询
        $("#btnSelect").click(function () {
            tabInsertDetailSearch();
            $("#zuhechaxunfrom [type='reset']").click();//重置表单
            $("#BenCiYingF").val(0);//本次应付  就是一开始让文本框显示值为0
            $("#BenCiYingS").val(0);//本次应收
            $("#JieSuanM").val(0);//结算金额
        });

        //点击确认按钮，把选中的结算表里面的那个收费ID对应的对账ID修改为页面跳转传过来的对账ID
        $("#btnYes").click(function () {
            var check = $("#tabInsertDetail input:checked");
            var myArray = new Array(); //声明一个数组
            for (var i = 0; i < check.length; i++) {
                myArray[i] = check[i].value;
            }
            if (check.length == 0) {
                layer.alert("请选择需要进行确认对账的客户数据!");
            }
            else if (check.length > 0) {
                var BCYShou = $("#BenCiYingS").val(); //应收
                var BCYFu = $("#BenCiYingF").val(); //应付
                var SettleMoney = $("#JieSuanM").val(); //结算金额

                layer.confirm("确定进行确认对账吗？",
               { icon: 3, btn: ['确定', '取消'] }, function (layerIndex) {
                   layer.close(layerIndex);
                       $.ajax({
                           url: "SaveInsertDetail?myArray=" + myArray + "&BCYShou=" + BCYShou + "&BCYFu=" + BCYFu + "&SettleMoney=" + SettleMoney,//选择的checkbox的value值
                           type: "get",//数据传输通道的类型
                           async: false,
                           dataType: "json",//传输的数据的类型
                           success: function (data) {//直接理解为回调函数
                               if (data == "success") {
                                   layer.alert("添加新增明细确认成功!");
                                   tabInsertDetail.refreshPage();
                               } else {
                                   layer.alert("添加确认失败!");
                               }
                           }
                       });
               })
            }
        })

        //自定义 操作列(每条数据后面的编辑按钮)
        function setOperate(record, rowIndex, colIndex, options) {
            var ChargeID = record.ChargeID;
            var btns = "<input type=button class='btn btn-sm btn-brown' value='编辑' onclick=Update(" + ChargeID + ") />";
            
            return btns;
        }

        //点击编辑按钮，进行数据回填
        function ChargeInfor(record) {
            $("#ChargeID").val(record.ChargeID);//收费ID
            $("#ReckoningUnit1").val(record.ReckoningUnit);//结算单位
            $("#EtrustNmber1").val(record.EtrustNmber);//委托单号
            $("#ExpenseName1").val(record.ExpenseName);//费用名称
            $("#SettleAccounts1").val(record.SettleAccounts);//收付款类型
            $("#UnitPrice1").val(record.UnitPrice);//单价金额
            $("#Parities1").val(record.Parities);//汇率
        }

        //点击每条数据后面的编辑按钮，弹出编辑应收应付模态框
        function Update(ChargeID) {
            $("#modBaseInfor").modal();
        }

        //点击编辑应收应付模态框的确定按钮，保存修改的数据
        $("#BtnSave").click(function () {
            //获取页面数据
            var ChargeID = $("#ChargeID").val();
            var UnitPrice = $("#UnitPrice1").val().trim();

            $.post("SaveUpdateDetail", { ChargeID: ChargeID, UnitPrice: UnitPrice }, function (msg) {
                if (msg == "success") {
                    layer.alert("编辑修改成功!");
                    $("#modBaseInfor").modal('hide');
                    tabInsertDetail.refreshPage();
                }
                else {
                    layer.alert("编辑修改失败，请重新检查一遍!");
                }
            })
        })





     

        //点击关闭按钮跳转到财务结算页面
        $("#btnGuanbi").click(function () {
            window.location.href = "/Commerce/Examine/FinanceIndex";
        })


    </script>


</body>
</html> 